package win.smartown.mistyle.util;

import android.content.res.Resources;
import android.support.design.widget.Snackbar;
import android.util.TypedValue;
import android.view.View;
import android.widget.TextView;

import win.smartown.mistyle.demo.R;

/**
 * Author:Smartown
 * Date:2017/3/19 19:58
 * Description:
 */
public class SnackbarUtil {

    public static Snackbar newSnackbar(View rootView) {
        Snackbar snackbar = Snackbar.make(rootView, "", 0);
        Resources resources = rootView.getResources();
        snackbar.getView().setBackgroundColor(resources.getColor(R.color.snack_bar_back));

        TextView textView = (TextView) snackbar.getView().findViewById(android.support.design.R.id.snackbar_text);
        textView.setTextColor(resources.getColor(R.color.snack_bar_text_color));
        textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimensionPixelSize(R.dimen.snack_bar_text_size));

        TextView actionTextView = (TextView) snackbar.getView().findViewById(android.support.design.R.id.snackbar_action);
        actionTextView.setTextColor(resources.getColor(R.color.snack_bar_action_color));
        actionTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimensionPixelSize(R.dimen.snack_bar_action_size));
        return snackbar;
    }

}
